package com.ie.cloud.payment.controller;

import com.alibaba.fastjson.JSONObject;
import com.icbc.api.response.RefundResponseV1;
import com.ie.cloud.payment.config.aop.MethodLog;
import com.ie.cloud.payment.dto.RefundOrderAdd;
import com.ie.cloud.payment.service.impl.RefundOrderServiceImpl;
import com.ie.cloud.payment.vo.base.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * Created with FR
 *
 * @Author: DQ
 * @Date: 2025/07/21/17:20
 * @Description: 描述语句
 */
@Tag(name = "订单管理")
@RestController
@RequestMapping("/api/myRefundPayOrder")
@Validated
public class RefundOrderController {

    @Resource
    private RefundOrderServiceImpl refundOrderService;

    /**
     * 创建退款订单
     */
    @Operation(summary = "创建退款订单")
    @PostMapping("/create")
    @MethodLog(remark = "创建退款订单")
    public ResponseEntity<Result<JSONObject>> createOrder(@Validated @RequestBody RefundOrderAdd add) {
        return ResponseEntity.ok(refundOrderService.refundOrder(add));

    }


    /**
     * 开始退款
     */
    @Operation(summary = "开始退款")
    @GetMapping("/start-refund")
    @MethodLog(remark = "开始退款")
    public ResponseEntity<Result<RefundResponseV1>> startRefund(@RequestParam("refundOrderId") String refundOrderId) {
        return ResponseEntity.ok(refundOrderService.startRefund(refundOrderId));
    }
}
